package Levels;

import java.awt.Graphics;
import java.awt.Image;
import java.awt.geom.AffineTransform;
import java.util.ArrayList;

import Game.Dude;
import Game.Entity;
import Game.ImageLoader;
import Game.IndexCounter;
import Game.Movement;
import Game.Portal;
import Game.Projectile;
import Game.Sprite;
import Game.Wall;
import LifeForms.Chaser;

public abstract class Level {
	public Movement movem=new Movement();
	int x=0,y=0,nx=0,ny=0;
	int xBound=1500;
	int yBound=1500;
	int xScale=756;
	int yScale=1128;
	public ArrayList<Entity> objects=new ArrayList<Entity>();
	ArrayList<Dude> chars=new ArrayList<Dude>();
	ArrayList<Projectile> projectiles=new ArrayList<Projectile>();
	ArrayList<Portal> portals=new ArrayList<Portal>();
	public ArrayList<Chaser> chasers=new ArrayList<Chaser>();
	
	public Level(){
	}
	public int getX(){
		return x;
	}
	public int getY(){
		return y;
	}
	public void scrollScreen(Dude character){
		if(x<=756){
			if (character.x>600+x&&character.getHorMove()>0){
				x++;
			}
		}
		if(x>=0){
			if (character.x<150+x&&character.getHorMove()<0){
				x--;
			}
		}
		if(y<=1128){
			if (character.y>250+y&&character.getVerMove()>0){
				y++;
			}
		}
		if(y>=0){
			if (character.y<100+y&&character.getVerMove()<0){
				y--;
			}
		}
	}
	public void update(){
		for(Dude d:chars){
			if(d.getHealth()<=0){
				System.exit(0);
			}
		}
		for(Projectile p:projectiles){
			p.move();
		}
//		System.out.println(projectiles.size());
		for(int i=0;i<chasers.size();i++){
			chasers.get(i).move();
		}
		l_update();
	}
	public void paint(Graphics g){
		l_paint(g);
		for(Projectile p:projectiles){
			p.Draw(g, 0, x, y);
		}
		for (int i=0;i<chars.size();i++) {
			g.drawString("health: "+chars.get(i).getHealth(),660,15);
			g.drawString("Ammo: "+chars.get(i).getAmmo(),660,30);
		}
	}
	abstract void l_update();
	abstract void l_paint(Graphics g);
}
